package net.pulseproject.router.app.view;

import javax.swing.text.JTextComponent;

import net.pulseproject.commons.misc.binder.StringBinder;
import net.pulseproject.router.app.model.ModelField;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class ModelTextComponentBinder extends StringBinder<ModelField> {

	private static final Log LOG = LogFactory.getLog(ModelTextComponentBinder.class);
	
	private final JTextComponent textComponent;

	
	public ModelTextComponentBinder(final ModelField field, final JTextComponent textComponent) {
		super(field);
		this.textComponent = textComponent;
	}

	@Override
	public final void onTypedValueSet(final String value) {
		LOG.debug("onTypedValueSet(value)");
		this.textComponent.setText(value);
	}
	
	@Override
	public final String toString() {
		return "ModelTextComponentBinder[field=" + this.getField() + "]";
	}
}
